package com.acme.bankapp.domain.bank;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Date;

import com.acme.bankapp.listeners.ClientRegistrationListener;
import com.acme.bankapp.listeners.EmailNotificationListener;
import com.acme.bankapp.listeners.PrintClientListener;

public class Bank implements Serializable {
	private int i;
	private Client masclient[] = new Client[10];
	private ClientRegistrationListener listener[] = {
			new PrintClientListener(), new EmailNotificationListener(),
			new DebugListener() };

	public void addclient(Client cl) {
		masclient[i] = cl;
		i++;
		for (ClientRegistrationListener creg : listener) {
			creg.onClientAdded(cl);
		}
		System.out.println();
	}

	class DebugListener implements ClientRegistrationListener, Serializable {

		@Override
		public void onClientAdded(Client c) {
			Date dat = new Date();
			System.out.println(dat);
		}

	}

	public Client[] getClients() {
		return masclient;
	}

	public Client getClient(int i) {
		return masclient[i];
	}

	@Override
	public String toString() {
		return "Bank [i=" + i + ", masclient=" + Arrays.toString(masclient)
				+ "]";
	}

}
